package com.xy.biz.base.domain.req;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.Objects;

@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class GetGoodsBatchByGoodsAndBatchRequest {

    private Long goodsId;

    private String goodsCode;

    @NotNull
    private String goodsBatchCode;

    @Override
    public boolean equals(Object obj) {
        if(this == obj) {
            return true;
        }
        if(obj instanceof GetGoodsBatchByGoodsAndBatchRequest) {
            GetGoodsBatchByGoodsAndBatchRequest target = (GetGoodsBatchByGoodsAndBatchRequest)obj;
            return Objects.equals(this.goodsId, target.getGoodsId())
                    && Objects.equals(this.goodsCode, target.getGoodsCode())
                    && Objects.equals(this.goodsBatchCode, target.getGoodsBatchCode());
        }

        return false;
    }

    @Override
    public int hashCode() {
        if(this.goodsId != null
                && this.goodsBatchCode != null) {
            long code = this.goodsId ^ this.goodsBatchCode.hashCode();
            return (int)(code ^ code >>> 32);
        }
        if(this.goodsCode != null
                && this.goodsBatchCode != null) {
            long code = this.goodsCode.hashCode() ^ this.goodsBatchCode.hashCode();
            return (int)(code ^ code >>> 32);
        }
        return 0;
    }

}
